/**
 * 创建于：2016-5-11
 * 创建人：杨骐彰
 * 说明： 主页面页面顶部
 */
import React from 'react'
import {withRouter} from 'react-router'
import './navbar.scss'
import auth from 'auth'
import icons from 'icons'
import {Link} from 'react-router'

const RoleEnum = {
  1:{
    name:'超级管理员',
    value:1
  },
  2:{
    name:'普通管理员',
    value:2
  },
  3:{
    name:'普通用户',
    value:3
  },
  4:{
    name:'安装管理员',
    value:4
  },
  128:{
    name:'超级管理员',
    value:1
  },
};
const RoleMap = new Map(Object.entries(RoleEnum));

const Header = (props)=>(
    props && <div className="sem-navbar">
        <div className="brand">
            <img  className="icon"  src={icons.logo} />
            <img className='name' src={icons.logoName}/>
        </div>
        <ul className="nav">
                <li className="user" onClick={()=>props.handleClick()}>
                    <Link to='/home'>
                      <img className="icon" src={icons.indexIcon}/>
                      <p>
                        首页
                      </p>
                    </Link>
                </li>
            <li className="user">
                <Link to='/home/account' >
                    <img className="icon" src={icons.administrator}/>
                  {
                    RoleMap.get(props.userInfo.Type+'').name
                  }
                </Link>
            </li>
          <li className="reset-password">
            <Link to='/home/account' >
              <img className="icon" src={icons.passwordIcon}/>
              修改密码
            </Link>
          </li>
            <li className="logout" onClick={()=>{auth.unAuthorize(()=>{
                props.router.replace('/login')
            })}}>
                <a href="javascript:;">
                    <img className="icon" src={icons.logout}/>
                    退出
                </a>
            </li>
        </ul>
    </div>
);

export default withRouter(Header);
